<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <style type="text/css">
        body {
            margin: 50px
        }

        #out {
            height: 100px;
            width: 100%;
            position: relative;
            overflow: hidden;
        }

        #mid {
            position: absolute;
            left: 50%;
            width: 1000px;
            margin-left: -500px;
            text-align: center;
        }
    </style>
</head>
<body>
<div id="out">
    <div id="mid">
        <img src="http://i2.sinaimg.cn/blog/1/2008/0306/U2725P503T1D169F6DT20080822100708.jpg" width="500px"/>

    </div>
</div>
<script>
    window.onbeforeunload = function (event) {
        var message = 'Sure you want to leave?';
        if (typeof event == 'undefined') {
            event = window.event;
        }
        if (event) {
            event.returnValue = message;
        }
        return message;
    }
</script>
</body>
</html>
